package cn.zf233.springsecurityjwt.util;

import cn.zf233.springsecurityjwt.common.R;
import com.fasterxml.jackson.databind.ObjectMapper;

import javax.servlet.ServletResponse;
import java.io.IOException;
import java.io.OutputStream;

/**
 * Created by zf233 on 2021/7/14
 */
public class ServletUtil {

    public static void renderString(ServletResponse response, R r) throws IOException {
        response.setContentType("test/json;charset=utf-8");
        OutputStream out = response.getOutputStream();
        ObjectMapper om = new ObjectMapper();
        om.writeValue(out, r);
        out.flush();
        out.close();
    }
}
